package com.weitu.emergency.service.impl;

import com.weitu.emergency.entity.EmergencySuppliesStock;
import com.weitu.emergency.mapper.EmergencySuppliesMapper;
import com.weitu.emergency.mapper.EmergencySuppliesStockMapper;
import com.weitu.emergency.service.EmergencySuppliesStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @author zhangqingxi 2017-05-10
 */
@Service
public class EmergencySuppliesStockServiceImpl implements EmergencySuppliesStockService{

    private final EmergencySuppliesStockMapper emergencySuppliesStockMapper;
    private final EmergencySuppliesMapper emergencySuppliesMapper;


    @Autowired
    public EmergencySuppliesStockServiceImpl(EmergencySuppliesStockMapper emergencySuppliesStockMapper, EmergencySuppliesMapper emergencySuppliesMapper) {
        this.emergencySuppliesStockMapper = emergencySuppliesStockMapper;
        this.emergencySuppliesMapper = emergencySuppliesMapper;
    }

    @Override
    public List<EmergencySuppliesStock> findByParam(Map paramMap) {

        return emergencySuppliesStockMapper.findByParam(paramMap);
    }

    @Override
    public Integer findByParamCount(Map paramMap) {
        return emergencySuppliesStockMapper.findByParamCount(paramMap);
    }

    @Override
    public EmergencySuppliesStock findById(String id) {
        return emergencySuppliesStockMapper.findById(id);
    }


    @Override
    public Integer add(Map paramMap) {
        return emergencySuppliesStockMapper.add(paramMap);
    }

    @Transactional
    @Override
    public Integer add(Map stockMap, Map suppliesMap) {

        emergencySuppliesMapper.updateById(suppliesMap);
        return emergencySuppliesStockMapper.add(stockMap);
    }

    @Override
    public Integer updateById(Map paramMap) {
        return emergencySuppliesStockMapper.updateById(paramMap);
    }
}
